M-Bus to LoRaWAN - Secondary Addressing
Integration manual for the ACRIOS Systems converters ACR-CV-101L-M-D and ACR-CV-101L-M-EAC with focus on secondary addressing.
Introduction
This converter is used to retrofit existing meters with M-Bus communication to LoRaWAN communication.
Following link refers to a Lua script used within the documentation, it contains all the mentioned configuration options and functions:
M-Bus to LoRaWAN - Secondary Addressing LUA script
Keep in mind that older M-Bus meters lack secondary addressing because early standards and hardware did not support it. Secondary addressing became widely supported post-2010 as the M-Bus standard evolved and systems scaled in complexity - thus it is safe to assume all models from 2015 and later are compatible. If you encounter issues with older meters, you may need to consider retrofitting or upgrading your network to accommodate modern addressing methods.
Feel free to contact us for possible solutions.
Typical Use-Case
Efficient monitoring and management of heat meters plays a crucial role in optimization of energy consumption and overall operational effectiveness in the realm of district heating stations. The integration of the M-Bus to LoRaWAN converter presents a streamlined solution that allows for quick deployment and seamless connectivity for heat meter data, ensuring real-time insights and efficient control.
Scenario:
Imagine a district heating station serving a residential complex. This facility relies on a network of heat meters installed within individual apartments to monitor the heat consumption accurately. The challenge is to efficiently collect and transmit this consumption data to a central management system for billing, monitoring, and maintenance purposes.
Solution:
To overcome this challenge, the Lua script used in conjunction with ACRIOS Systems's converters incorporates Virtual ID Field Differentiation (VIF DIF) filtering. This addition provides notable benefits, including a significant reduction in transmitted bytes which comes handy given the constraints of LoRaWAN. This is particularly useful since many devices can generate large M-Bus frames.
Benefits:
- Time and Cost Savings: The quick installation process eliminates unnecessary configuration and wiring efforts, reducing installation time and associated costs.
- Seamless Integration: The plug-and-play nature of the solution simplifies the integration of heat meters into the district heating network, minimizing disruption to residents.
- Reliable Communication: The external antenna ensures reliable signal propagation, maintaining consistent communication even in complex architectural environments.
- Real-Time Insights: The solution provides real-time heat consumption data, enabling accurate billing and informed decision-making for energy optimization.
- Remote Configuration: Both the device configuration and its software can be maintained remotely thanks to the utilization of two-way communication protocol.
What Is M-Bus?
M-Bus (Meter-Bus) is a European standard (EN 13757-2 physical and link layer, EN 13757-3 application layer) for the remote reading of water meter, gas or electricity meters. M-Bus is also usable for other types of consumption meters. The M-Bus interface is made for communication on two wires, which is very cost-efficient. There is also a radio variant of M-Bus (Wireless M-Bus), specified in EN 13757-4.
Data on the M-Bus is transferred in telegrams which consist of one or more frames, there must be no pauses within telegrams, not even after stop bits. M-Bus uses four different telegram formats with the following structures:
Single Character | Short Frame | Control Frame | Long Frame |
---|---|---|---|
E5h | Start 10h | Start 68h | Start 68h |
C Field | L Field = 3 | L Field | |
A Field | L Field = 3 | L Field | |
Check Sum | Start 68h | Start 68h | |
Stop 16h | C Field | C Field | |
A Field | A Field | ||
CI Field | CI Field | ||
Check Sum | User Data (0-252 Byte) | ||
Stop 16h | Check Sum | ||
Stop 16h |
❗ When communicating with more meters on the same M-Bus line, it is crucial to provide each slave unit with individual address (A Field). Meter can be addressed by its primary address or by its secondary address.
Primary Addressing:
Address | Function |
---|---|
0 | Factory default address. |
1-250 | Addresses that can be assigned to slaves. (Primary addresses) |
251-252 | Reserved for future use. |
253 | Indicates that addressing is performed at the network layer instead. (Secondary addressing procedure) |
254 | Broadcast, meters reply with their addresses. (Causes collision, test purposes only) |
255 | Broadcast, meters do not reply. |
The secondary address consists of 4 parts:
- 4 bytes being the device ID (serial #)
- 2 bytes being the manufacturer’s identifier
- 1 byte being the device version
- 1 byte being the device media
The benefit of secondary addressing is that there is no need to reconfigure meter’s primary addresses and the installation can be navigated only by modifying the converters’ addressing mechanism.
Converter Integration
Functions
- Adaptable payload fragmentation length
- Configurable reading period (default interval: 1 hour)
- Configurable initial M-bus delay (default length: 5,000 ms)
- Configurable M-Bus parameters
- Configurable port
- Configurable VIF DIF filtering
- Remote configuration using specific commands
Out of the Box Behavior
By default after connecting the meter to the converter and powering up, the device will first scan for any available M-bus devices.
This is how it looks on first onStartup():
Initialization:
[ 147][SYS]: console ready
[ 150][MEM]: init done, heap 48160 bytes, bss 12472 bytes, stack 4128 bytes
[ 2738][SYS]: Reset Reason: BOR reset
[ 2742][SYS]: FW version: CV_FW_2.13.7
[ 2749][SYS]: Model: ACR_CV_101L_M_D
[ 2753][SYS]: SN: 1111
[ 2756][SYS]: date / time - 2016/01/01 / 00:00:02
[ 2761][SYS]: build date / time - Jan 10 2024 / 22:14:26
Loading the Lua script and starting the onStartup() section:
[ 7347][STDOUT]: MBus-LoRaWAN, V2.0
[ 7838][STDOUT]: ACR_CV_101L_M_D
M-Bus scan:
[ 7910][HWAPI_MBUS]: MBUS FILTER not set!
[ 23229][STDOUT]: Params: 1 500 0 1
[ 25138][MBUS]: found id = 0x22003287, manid = 0x7704, ver = 0x14, medium = 0x07
[ 29287][STDOUT]: Old filter:
[ 29330][STDOUT]: 22003287 not in existing, add
[ 29394][STDOUT]: New filter:
[ 29441][STDOUT]: 1 = 22003287
[ 29498][STDOUT]: New VIF DIF filter:
[ 29547][STDOUT]: 1 = 00000000
When the scan is finished, the device sends a "Scan done" report. It's distinguished by the third byte F5
.
More about the command bytes are described in Commands section.
Sending the data to LoRaWAN:
[ 29897][STDOUT]: TX:
[ 30126][STDOUT]: V = 3605 mV
00 : 01 01 F5 01 87 32 00 22 77 04 14 07
[ 30212][LORA]: Force confirmed message after join!
[ 30218][LORA]: Not joined, join and continue.
[ 30249][LORAMAC]: # === MLME-Request == #
[ 30254][LORAMAC]: # MLME_JOIN #
[ 30261][LORAMAC]: # ===== #
[ 30265][LORAMAC]: STATUS : OK
[ 30272][LORAMAC]: # == CTXS STORED == #
[ 30277][LORAMAC]: Size : 1112
[ 35514][LORAMAC]: # === MLME-Confirm == #
[ 35519][LORAMAC]: STATUS : OK
[ 35524][LORAMAC]: # === JOINED == #
[ 35529][LORAMAC]: OTAA
[ 35532][LORAMAC]: DevAddr : 0007AAA9
[ 35538][LORAMAC]:
[ 35540][LORAMAC]: DATA RATE : DR_4
[ 35549][LORAMAC]: # == CTXS STORED == #
[ 35554][LORAMAC]: Size : 1088
[ 35649][LORAMAC]: # === MCPS-Request == #
[ 35655][LORAMAC]: # MCPS_CONFIRMED #
[ 35662][LORAMAC]: # ===== #
[ 35666][LORAMAC]: STATUS : OK
[ 40870][LORAMAC]: # === MCPS-Confirm == #
[ 40876][LORAMAC]: STATUS : OK
[ 40880][LORAMAC]: # = UPLINK FRAME 1 = #
[ 40887][LORAMAC]:
[ 40890][LORAMAC]: CLASS : A
[ 40894][LORAMAC]:
[ 40897][LORAMAC]: TX PORT : 100
[ 40901][LORAMAC]: TX DATA : CONFIRMED - ACK
[ 40907][LORAMAC]: 01 01 F5 01 87 32 00 22 77 04 14 07
[ 40914][LORAMAC]:
[ 40917][LORAMAC]: DATA RATE : DR_4
[ 40922][LORAMAC]: U/L FREQ : 867300000
[ 40927][LORAMAC]: TX POWER : 0
[ 40932][LORAMAC]: CHANNEL MASK: 00FF
[ 40937][LORAMAC]:
[ 40939][LORAMAC]: # == MCPS-Indication == #
[ 40945][LORAMAC]: STATUS : OK
[ 40949][LORAMAC]: # = DOWNLINK FRAME 0 = #
[ 40956][LORAMAC]: RX WINDOW : 1
[ 40960][LORAMAC]: RX PORT : 0
[ 40965][LORAMAC]:
[ 40967][LORAMAC]: DATA RATE : DR_4
[ 40972][LORAMAC]: RX RSSI : -87
[ 40977][LORAMAC]: RX SNR : 13
[ 40981][LORAMAC]:
[ 40987][LORAMAC]: # == CTXS STORED == #
[ 40992][LORAMAC]: Size : 472
[ 41068][LORA]: Continue unconfirmed msg.
[ 41103][STDOUT]: RX:
Throughout the sending process, the converter autonomously verifies its connection to the network server. If it detects a lack of connectivity, it automatically initiates a join request. The preceding text illustrates the successful execution of the join procedure.
onWake function:
In this section, the converter sends an M-Bus request to the connected devices and relays the received frame directly to the Network server. When this part is finished, it's followed by a "Gather report" (F4
). Finally, the converter transitions into a sleep mode for the designated duration.
[ 48246][STDOUT]: TX:
[ 48474][STDOUT]: V = 3605 mV
00 : 01 01 00 68 0F 0F 68 08 00 72 87 32 00 22 77 04
10 : 14 07 3D 30 00 00 58 16
[ 48585][LORAMAC]: # === MCPS-Request == #
[ 48590][LORAMAC]: # MCPS_CONFIRMED #
[ 48597][LORAMAC]: # ===== #
[ 48601][LORAMAC]: STATUS : OK
...
[ 53956][STDOUT]: RX:
[ 54039][STDOUT]: TX:
[ 54267][STDOUT]: V = 3604 mV
00 : 01 01 F4 01 01
[ 54365][LORAMAC]: # === MCPS-Request == #
[ 54370][LORAMAC]: # MCPS_CONFIRMED #
[ 54377][LORAMAC]: # ===== #
[ 54381][LORAMAC]: STATUS : OK
...
[ 59697][STDOUT]: RX:
[ 59705][SYS]: entering sleep mode
For a more comprehensive understanding, please refer to the Commands sections below.
Hardware Used
- ACR-CV-101L-M-D - M-Bus to LoRaWAN converter, battery powered
- ACR-CV-101L-M-EAC - M-Bus to LoRaWAN converter, externally powered
The converter allows connection to any meter or other device equipped with an M-Bus communication.
Hardware Limitations
-
The hardware allows connecting up to 5 Unit Loads (UL) to an M-Bus line.
-
The typical battery lifetime is:
Reading and Sending Interval | Battery Lifetime |
---|---|
15 min | 2.7 years |
30 min | 5.4 years |
60 min | 10.8 years |
This measuring was done with one M-Bus device and VIF DIF filter activated, so the payload fits a single LoRaWAN message.
Calculation was done with a single D-cell battery (19000 mAh).
In case of a longer M-Bus connection (approximately 380 meters between the meter and converter), a termination resistor (5.5 kohm) is required. This applies only for new generation (NG) of M-Bus converter (the device that allows up to 16 UL), low amount of UL and long connection (for example 380m).
Application Limitations
- From the nature of LoRaWAN communication it might be needed to adjust the payload size since only up to 51 bytes can be sent with SF12.
- This solution overcomes this limitation by fragmentation of the payload. In addition, VIF DIF filter can be used to reduce the M-Bus frame size and the final payload. It also checks for the current data rate and adjusts the payload size accordingly.
- From the nature of LoRaWAN communication it is needed to be cautious when connecting multiple sensors with frequent readings as the communication might be limited by the duty cycle.
- As much as autonomous the communication is, the user still needs to be cautious about the wake-up period and the length of the payload. If the duty cycle exceeds the limit, the device will drop the payload and attempt to send another one next time.
Uplink Commands
F4
- Gather Report AckedF5
- M-Bus Scan DoneF6
- M-Bus IDs ChecksumFA
- Status ReportFE
- Configuration Acknowledge
Gather Report (0xF4)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xF4 | Command byte | [1B] | 3 |
0x02 | Relative counter | [1B] | 4 |
0x01 | IDs received | [1B] | 5 |
M-Bus Scan Done (0xF5)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xF5 | Command byte | [1B] | 3 |
0x01 | Apply found devices to the filter | [1B] | 4 |
0x60 0x53 0x47 0x01 | ID 01475360 | [4B] | 5-8 |
0x42 0x04 | MAN ID 0442 | [2B] | 9-10 |
0x20 | Version | [1B] | 11 |
0x02 | Medium | [1B] | 12 |
0x31 0x57 0x54 0x01 | ID 01545731 | [4B] | 13-16 |
0x42 0x04 | MAN ID 0442 | [2B] | 17-18 |
0x20 | Version | [1B] | 19 |
0x02 | Medium | [1B] | 20 |
0xXX | N*IDs | [xB] | x |
Apply found devices to the filter:
- 00 - Do not add or apply any IDs.
- 01 - Add only scanned IDs (if an ID is stored in the memory, but not received during the scan, it is removed).
- 02 - Add only newly found IDs.
M-Bus IDs Checksum (0xF6)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xF6 | Command byte | [1B] | 3 |
0x01 | Filter length [= N] | [1B] | 4 |
0x87 32 00 23 | Checksum | [4B] | 5-8 |
The checksum is calculated with bitwise XOR:
RES1 = 0 ⊕ (ID1) => 0 ⊕ 0x87320020 = 0x87320020
RES2 = (RES1) ⊕ (ID2) => 0x87320020 ⊕ 0x87320021 = 0x01
RES3 = (RES2) ⊕ (ID3) => 0x01 ⊕ 0x87320022 = 0x87320023
…
RESN = (RESN-1) ⊕ (IDN)
The example above shows the checksum for IDs 20003287, 21003287, and 22003287 looks like this: 0x87320023.
Status Report (0xFA)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xFA | Command byte | [1B] | 3 |
0x32 2E 30 | LUA script ASCII version (2.0) | [3B] | 4-6 |
Configuration Acknowledge (0xFE)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 0x01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xFE | Command byte | [1B] | 3 |
0x00 | Wake-up period (days) | [1B] | 4 |
0x01 | Wake-up period (hours) | [1B] | 5 |
0x00 | Wake-up period (minutes) | [1B] | 6 |
0x01 | Filter length | [1B] | 7 |
0x01 | Configuration version | [1B] | 8 |
0x60 0x09 | M-Bus baudrate | [2B] | 9-10 |
0x03 | Retry M-Bus reading | [1B] | 11 |
0xB8 0x0B | M-Bus timeout | [2B] | 12-13 |
0x02 | OnStartup Scan mode | [1B] | 14 |
0x00 | VIF/DIF filter index 1 | [1B] | 15 |
0xFF | VIF/DIF filter index 2 | [1B] | 16 |
0xFF | VIF/DIF filter index 3 | [1B] | 17 |
0xFF | VIF/DIF filter index 4 | [1B] | 18 |
0xFF | VIF/DIF filter index 5 | [1B] | 19 |
0xFF | VIF/DIF filter index 6 | [1B] | 20 |
0xFF | VIF/DIF filter index 7 | [1B] | 21 |
0xFF | VIF/DIF filter index 8 | [1B] | 22 |
0xFF | VIF/DIF filter index 9 | [1B] | 23 |
0xFF | VIF/DIF filter index 10 | [1B] | 24 |
0xFF | VIF/DIF filter index 11 | [1B] | 25 |
0xFF | VIF/DIF filter index 12 | [1B] | 26 |
0xFF | VIF/DIF filter index 13 | [1B] | 27 |
0xFF | VIF/DIF filter index 14 | [1B] | 28 |
0xFF | VIF/DIF filter index 15 | [1B] | 29 |
0xFF | VIF/DIF filter index 16 | [1B] | 30 |
0x01 | VIF/DIF filter amount | [1B] | 31 |
0x02 | VIF/DIF filter bytes | [1B] | 32 |
0x04 0x13 | VIF/DIF filter | [2B] | 33-34 |
VIF/DIF filter index X enables/disables a specific VIF/DIF filter for the ID with the given index.
From the example above, the last bytes 01 02 04 13
specify the VIF/DIF filter itself:
01
- is the number of VIF/DIF filters for group 0, which is 1 filter.02
- is the number of following bytes, which is 2 bytes.04 13
- is the VIF/DIF filter.
For a more detailed explanation, please see the section Send Configuration (port = 02).
Initial Delay Report (0xF0 0x10)
Payload Description
Example | Description | Size | Byte Number |
---|---|---|---|
0x01 01 | Packet count (1 out of 1) | [2B] | 1-2 |
0xF0 10 | Command byte | [2B] | 3-4 |
0xA0 0F | Initial delay | [2B] | 5-6 |